/*
 * key.h
 *
 *  Created on: 2020年11月15日
 *      Author: Administrator
 */

#ifndef KEY_H_
#define KEY_H_

/* Private includes ----------------------------------------------------------*/
#include "Cpu.h"
#include <stdio.h>
#include <stdint.h>
#include "tim.h"

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/
#define BTN1 ((PINS_DRV_ReadPins(PTC) >> 12) & 0x01)
#define BTN2 ((PINS_DRV_ReadPins(PTC) >> 13) & 0x01)
#define BTN3 ((PINS_DRV_ReadPins(PTB) >> 2) & 0x01)

#define BTN1_PRES 1
#define BTN2_PRES 2
#define BTN3_PRES 3

#define keyNUM        3
#define KEYMASK       0x07
#define RESTAINMASK   0x07
#define RESTAIN_TIMES 100

#define keyTrg0 keyTrg[0].bits.b0
#define keyTrg1 keyTrg[0].bits.b1
#define keyTrg2 keyTrg[0].bits.b2

#define restainKeyTrg0 keyTrg[1].bits.b0
#define restainKeyTrg1 keyTrg[1].bits.b1
#define restainKeyTrg2 keyTrg[1].bits.b2
/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/
extern _TKS_FLAGA_type keyTrg[2];  // 按键触发标志
/* Private function prototypes -----------------------------------------------*/
unsigned char KEY_Proc(unsigned char mode);

void keyInit(void);
void keyScan(void);

/* Private user code ---------------------------------------------------------*/

#endif /* KEY_H_ */
